package Test;

import java.util.Comparator;
import java.util.PriorityQueue;

class IntCom implements Comparator<Integer> {
    public int compare(Integer i1, Integer i2) {
        //return i1.compareTo(i2);//从小到大
        return i2.compareTo(i1);//从大到小
    }
}


public class test {
    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new IntCom());

        //默认小根堆
        priorityQueue.offer(3);
        priorityQueue.offer(2);
        priorityQueue.offer(1);

        System.out.println(priorityQueue.peek());
    }
}
